//
//                       _oo0oo_
//                      o8888888o
//                      88" . "88
//                      (| -_- |)
//                      0\  =  /0
//                    ___/`---'\___
//                  .' \\|     |// '.
//                 / \\|||  :  |||// \
//                / _||||| -:- |||||- \
//               |   | \\\  -  /// |   |
//               | \_|  ''\---/''  |_/ |
//               \  .-\__  '-'  ___/-. /
//             ___'. .'  /--.--\  `. .'___
//          ."" '<  `.___\_<|>_/___.' >' "".
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//         \  \ `_.   \_ __\ /__ _/   .-` /  /
//     =====`-.____`.___ \_____/___.-`___.-'=====
//                       `=---='
//
//
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//               佛祖保佑         永无BUG
//
//
//                          @王帅
package com.basics.controller;

import com.basics.model.Dj;
import com.basics.model.User;
import com.basics.service.AutoService;
import com.basics.service.IUserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/auto")
public class AutoController {

    @Resource
    private AutoService autoService;
    @ResponseBody
    @RequestMapping("/showDaAn.do")
    public List<String>   selectUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String input = request.getParameter("timu");

        String tag = "span";
        String result =   HtmlRegexpUtil.filterHtml(input);
        String[] li =  result.split("选题|A");

        String dj="";
        List<String> Anslist= new ArrayList<>();
        int tihao = 1;
//        for (int i=1 ;i<=li.length-2;i=i+2) {
   for (int i=0 ;i<li.length;i++) {
                String timu = "%"+li[i]+"%";
/**/
                Dj djAll = this.autoService.selectByTiMu(timu);
                if (djAll==null){
                   String  add="空"+".";
                    Anslist.add(add);
                    dj=dj+add;
                }else{
                    String daan = djAll.getDaan();
                    String  add= daan+".";
                    Anslist.add(add);
                  dj=dj+add;
                }

            tihao++;
        }

        return  Anslist;
    }

}